package de.jmda.gen.java.impl;

import de.jmda.gen.GeneratorException;
import de.jmda.gen.impl.DefaultGenerator;
import de.jmda.gen.java.TypeNameGenerator;

/**
 * @author roger.jmda@gmail.com
 */
public class DefaultTypeNameGenerator
		extends DefaultGenerator
		implements TypeNameGenerator
{
	public final static String DEFAULT_TYPE_NAME = Void.TYPE.getName();

	public DefaultTypeNameGenerator()
	{
		this(DEFAULT_TYPE_NAME);
	}

	public DefaultTypeNameGenerator(String input)
  {
	  super(notNull(input));
  }

	@Override
  public void setTypeName(String typeName)
  {
		setOutput(notNull(typeName));
  }

	@Override
  public String getTypeName() throws GeneratorException
  {
	  return generate().toString();
  }

	private static String notNull(String input)
  {
		if (input == null)
		{
			return DEFAULT_TYPE_NAME;
		}

		return input;
  }
}